#include <stdio.h>
#include <math.h>
#include <memory.h>

int main()
{
    int i,j,n;
    bool su[32769];
    memset( su, 0, sizeof(su) );
    for ( i = 2; i <= 32768; i++)
    {
        if ( !su[ i ] )
            for ( j = i + i; j <= 32768; j +=i )
                su[ j ] = true;
    }
    while ( scanf("%d", &n) != EOF )
    {
        if ( n==0 ) break;
        int count = 0;
        for ( i = 2; i <= n / 2; i++ )
            if ( !su[ i ] && !su[ n - i ] ) count++;
        printf("%d\n", count);
    }
    return 0;
}
